<template>
	<div>
		<v-row>
			<v-col cols="12" md="4">
				<v-card class="mx-auto" max-width="500">
					<v-card-text>
						<p class="text-h4 text--primary text-center">
							月产值
						</p>
						<p class="text-h5 text--primary text-center"><span
								style="color: red;">{{month_productioncount}}</span> 万/月</p>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">单位：万/月</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">达成率：≥1200 万/月</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;"><a
									@click="productionValueReport">查看详情 > >
									></a></span>
						</p>
					</v-card-text>

					</v-card-actions>
				</v-card>
			</v-col>
			<v-col cols="12" md="4">
				<v-card class="mx-auto" max-width="500">
					<v-card-text>
						<p class="text-h4 text--primary text-center">
							采购交付率
						</p>
						<p class="text-h5 text--primary text-center"><span
								style="color: red;">{{procurement_deliverycount}}</span></p>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">单位：百分比</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">达成率：≥95%</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;"><a @click="procurementDeliveryReport"
									>查看详情 > >
									></a></span>
						</p>
					</v-card-text>

					</v-card-actions>
				</v-card>
			</v-col>
			<v-col cols="12" md="4">
				<v-card class="mx-auto" max-width="500">
					<v-card-text>
						<p class="text-h4 text--primary text-center">
							生产任务交付及时率
						</p>
						<p class="text-h5 text--primary text-center"><span
								style="color: red;">{{production_completecount}}</span> %</p>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">单位：百分比</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">达成率：≥95%</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;"><a @click="productionYieldRateReport">查看详情 > >
									></a></span>
						</p>
					</v-card-text>

					</v-card-actions>
				</v-card>
			</v-col>
			<v-col cols="12" md="4">
				<v-card class="mx-auto" max-width="500">
					<v-card-text>
						<p class="text-h4 text--primary text-center">
							产品直通率
						</p>
						<p class="text-h5 text--primary text-center"><span
								style="color: red;">{{product_oneokcount}}</span> %</p>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">单位：百分比</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">达成率：≥99%</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;"><a
									@click="productionPassReport">查看详情 > >
									></a></span>
						</p>
					</v-card-text>

					</v-card-actions>
				</v-card>
			</v-col>
			<v-col cols="12" md="4">
				<v-card class="mx-auto" max-width="500">
					<v-card-text>
						<p class="text-h4 text--primary text-center">
							盘点准确率
						</p>
						<p class="text-h5 text--primary text-center"><span
								style="color: red;">{{inventory_okcount}}</span> </p>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">单位：百分比（季度统计）</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">达成率：≥98%</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;"><a @click="inventoryOKReport">查看详情 > >
									></a></span>
						</p>
					</v-card-text>

					</v-card-actions>
				</v-card>
			</v-col>
			<v-col cols="12" md="4">
				<v-card class="mx-auto" max-width="500">
					<v-card-text>
						<p class="text-h4 text--primary text-center">
							人均劳动产出率
						</p>
						<p class="text-h5 text--primary text-center"><span
								style="color: red;">{{people_labor_resultcount}}</span> 万/月</p>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">单位：万/月</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;">达成率：≥8 万/月</span>
						<p class="text-h7 text--primary text-center"><span style="color: #cfcccc;"><a @click="percapitaGDPReport">查看详情 > >
									></a></span>
						</p>
					</v-card-text>

					</v-card-actions>
				</v-card>
			</v-col>
		</v-row>
		<v-card>

		</v-card>
	</div>
</template>

<script>
	import {
		mapState
	} from "vuex";
	export default {
		computed: {
			...mapState("admin/ua", {
				uaData: "data",
			}),
			...mapState('admin/user', [
				'info'
			])
		},
		data: () => ({
			userToken: {},
			valid: true,
			formState: true,
			rules: {
				nameRules: [
					(v) => !!v || "用户名不能为空",
					(v) => (v && v.length <= 10) || "用户名不能超过10个字符",
				],
			},
			//月产值
			month_productioncount: 0,
			//采购交付率
			procurement_deliverycount: 0,
			//生产任务达成率
			production_completecount: 0,
			//产品直通率（一次性检验通过率）
			product_oneokcount: 0,
			//盘点准确率
			inventory_okcount: 0,
			//人均劳动产出率
			people_labor_resultcount: 0,
			defaultShowStartDate:null,
			defaultShowEndtDate:null
		}),
		created() {
			this.loadProductionValueReport()
			this.loadProductionPassReport()
			this.loadProductionYieldRateReport()
			this.loadPercapitaGDPReport()
			this.loadProcurementDeliveryReport()
			this.loadInventoryOKReport()
		},
		methods: {
			async getUserInfo() {
				var response = await this.$httpRequest({
					url: 'Home/GetUserInfo',
					method: 'get'
				});
				if (response.status == 1) {
					this.userToken = response.data
					this.userToken.accountBookListToWeb = this.userToken.accountBookListToWeb.map(r => {
						return r.text
					})
				}
			},
			async loadProductionValueReport() {
				var response = await this.$httpRequest({
					url: 'MES/MESProductionValue/QueryPage',
					method: 'post'
				});
				if (response.status == 1) {
					this.month_productioncount = response.data.outtotalmoney
				}
			},
			async loadProductionPassReport() {
				var response = await this.$httpRequest({
					url: 'MES/MESProductQAPassReport/QueryPage',
					method: 'post'
				});
				if (response.status == 1) {
					this.product_oneokcount = response.data.checkPassRate
				}
			},
			async loadProductionYieldRateReport() {
				var response = await this.$httpRequest({
					url: 'MES/MESProductionYieldRate/QueryPage',
					method: 'post'
				});
				if (response.status == 1) {
					this.production_completecount = response.data.rate
				}
			},
			async loadPercapitaGDPReport() {
				var response = await this.$httpRequest({
					url: 'MES/MESPercapitaGDP/QueryPage',
					method: 'post'
				});
				if (response.status == 1) {
					this.people_labor_resultcount = response.data.rate
				}
			},
			async loadProcurementDeliveryReport(){
				var response = await this.$httpRequest({
					url: 'WMS/WmsReportIn/GetBillListByPage',
					method: 'get'
				});
				if (response.status == 1) {
					this.procurement_deliverycount = response.data.totalper
				}
			},
			async loadInventoryOKReport(){
				var response = await this.$httpRequest({
					url: `WMS/WmsReportCount/GetBillListByPage?year=${new Date().getFullYear()}`,
					method: 'get'
				});
				if (response.status == 1) {
					this.inventory_okcount = response.data.totalper
				}
			},
			currentDate() {
				var d = new Date()
				var str = '';
				str += d.getFullYear() + '-'; //获取当前年份 
				str += d.getMonth() + 1 + '-'; //获取当前月份（0——11） 
				str += d.getDate();
				// str += d.getDate() + '日';
				// str += d.getHours() + '时';
				// str += d.getMinutes() + '分';
				// str += d.getSeconds() + '秒';
				return str;
			},
			//月产值报表
			productionValueReport() {
				this.$router.push('/mes/reportor/mes_production_value')
			},
			//产品直通率报表
			productionPassReport() {
				this.$router.push('/mes/reportor/mes_production_qapass')
			},
			//生产任务交付及时率
      productionYieldRateReport(){
				this.$router.push('/mes/reportor/mes_production_yieldrate')
			},
			//人均劳动产出率
			percapitaGDPReport(){
				this.$router.push('/mes/reportor/mes_percapita_gdp')
			},
			//采购交付率
			procurementDeliveryReport(){
				this.$router.push('/wms/summary/report_in')
			},
			inventoryOKReport(){
				this.$router.push('/wms/summary/report_count')
			}

		},
	};
</script>
<style lang="scss">
</style>
